import * as types from "../types/recycleTypes";

const initialState = {
  banners: [],
  loading: false,
  initing: true,
  error: undefined,
  deviceName: "",
  deviceInfo: undefined,
  hotRecycleList: [],
};

export default function recycleReducer(state = initialState, action) {
  switch (action.type) {
    case types.RECYCLE_BANNER_INITING:
      return {
        ...state,
        initing: true,
      };
    case types.RECYCLE_BANNER_DONE:
      return {
        ...state,
        initing: false,
        loading: false,
        banners: action.banners,
      };
    case types.RECYCLE_BANNER_ERROR:
      return {
        ...state,
        initing: false,
        loading: false,
        error: action.error,
      };
    case types.RECYCLE_DEVICEINFO_DOWN:
      return {
        ...state,
        deviceInfo: action.deviceInfo,
      };
    case types.RECYCLE_DEVICENAME_DOWN:
      return {
        ...state,
        deviceName: action.deviceName,
      };
    case types.RECYCLE_DEVICEINFO_ERROR:
      return {
        ...state,
        initing: false,
        loading: false,
        deviceInfo: undefined,
      };
    case types.RECYCLE_HOTDEVICE_DOWN:
      return {
        ...state,
        initing: false,
        loading: false,
        hotRecycleList: action.hotRecycleList,
      };
    default:
      return state;
  }
}
